package com.wx.servicebase.rabbitMq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {

    /*定义队列*/
    @Bean
    public Queue queue(){
        return new Queue("registQueue",true);
    }

    /*定义交换机*/
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange("registExchange",true,false);
    }

    /*将交换机与队列通过路由绑定起来*/
    @Bean
    public Binding binding(){
        return BindingBuilder.bind(queue()).to(topicExchange()).with("regist");
    }
}
